<%@page import="com.wiseMen.platform.support.security.UserUtils"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<%@ include file="/WEB-INF/pages/common/taglib.jsp"%>
<%
    request.setAttribute("orgs", UserUtils.getCurrendUser().getOrgs());
%>
<html>
<head>
<title>请选择所属组织机构</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<%@ include file="/WEB-INF/pages/common/includeCoreCssJs.jsp"%>
</head>
<body>
	<div class="modal show">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<h2 class="text-center text-primary">选择登录部门</h2>
					<p class="text-center">双击或点击选择按钮</p>
				</div>
				<div class="modal-body">
					<table class="table table-striped table-hover" id="selectLoginOrgTable">
						<thead>
							<tr>
								<th></th>
								<th>部门名称</th>
								<th>全称</th>
							</tr>
						</thead>
						<tbody>
							<c:forEach items="${orgs}" var="org">
								<tr id="${org.id}">
									<td>
										<input type="radio" name="selectLoginOrgItem" value="${org.id}">
									</td>
									<td align="left">${org.name}</td>
									<td align="left">${org.fullName}</td>
								</tr>
							</c:forEach>
						</tbody>
					</table>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-primary" id="selectOrgBt">选择</button>
				</div>
			</div><!-- /.modal-content -->
		</div><!-- /.modal-dialog -->
	</div><!-- /.modal -->
	
	<%@ include file="/WEB-INF/pages/common/includeUiScript.jsp"%>
<script type="text/javascript">
$(function () {
	$('#selectLoginOrgTable input[name=selectLoginOrgItem]:first').click();
	$('#selectLoginOrgTable tbody tr').dblclick(function(){
        loginOrg($(this).attr("id"));
    });
	
	$("#selectOrgBt").click(function(){
		var id=$('#selectLoginOrgTable input[name=selectLoginOrgItem]:checked').val();
        if(id){
            loginOrg(id);
        }
	});
    
    function loginOrg(orgId){
    	window.location.href=ctx+"/user/loginOrg?orgId="+orgId;
    }
});
</script>
</body>
</html>

